import pandas as pd
from deep_translator import GoogleTranslator
from snownlp import SnowNLP
import time
df = pd.read_csv('评论数据 1005.csv')

# 初始化翻译器
translator = GoogleTranslator(source='auto', target='zh-CN')

# 遍历comment列并翻译
for idx, comment in enumerate(df['comment']):
    translated = translator.translate(str(comment))
    sentiment_score = SnowNLP(translated).sentiments
    print(sentiment_score)
